package ru.samgtu.wst.plugin;

import ru.samgtu.wst.model.ConversationID;
import ru.samgtu.wst.model.Request;
import ru.samgtu.wst.model.Response;
import ru.samgtu.wst.model.StoreException;

public interface Plugin extends Runnable {

	/**
	 * The plugin name
	 * 
	 * @return The name of the plugin
	 */
	String getPluginName();

	/**
	 * informs the plugin that the Session has changed
	 * 
	 * @param model
	 *            the new model
	 */
	void setSession(String type, Object store, String session)
			throws StoreException;

	/**
	 * starts the plugin running
	 */
	void run();

	boolean isRunning();

	/**
	 * called to test whether the plugin is able to be stopped
	 * 
	 * @return false if the plugin can be stopped
	 */
	boolean isBusy();

	/**
	 * called to determine what the current status of the plugin is
	 */
	String getStatus();

	/**
	 * called to suspend or stop the plugin
	 */
	boolean stop();

	/**
	 * called to determine whether the data stored within the plugin has been
	 * modified and should be saved
	 */
	boolean isModified();

	/**
	 * called to instruct the plugin to flush any memory-only state to the
	 * store.
	 * 
	 * @throws StoreException
	 *             if there is any problem saving the session data
	 */
	void flush() throws StoreException;

	void analyse(ConversationID id, Request request, Response response,
			String origin);

	Hook[] getScriptingHooks();

	Object getScriptableObject();

}
